<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>V3</title>

        <!-- Date: 2011-08-09 -->
    <style type="text/css">
    body,td,th {
	color: #000;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 11px;
}
body {
	background-color: #000;
}
    </style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery/thickbox-compressed.js"></script>
<LINK href="css/thickbox.css" rel="stylesheet" type="text/css">
    <style type="text/css">
    a:link {
	color: #000;
}
a:visited {
	color: #000;
}
a:hover {
	color: #FFF;
}
a:active {
	color: #000;
}
    a {
	font-size: 24px;
}
    </style>
    </head>
    <body>
        <table><tr><td valign=top>
                 
<span id="mycam">

          <!-- First, include the JPEGCam JavaScript Library -->
                    <script type="text/javascript" src="webcam.js"></script>

                    <!-- Configure a few settings -->
                    <script language="JavaScript">
                        webcam.set_api_url( 'test.php' );
                        webcam.set_quality( 100 ); // JPEG quality (1 - 100)
                        webcam.set_shutter_sound( true ); // play shutter click sound
                        webcam.set_stealth( true );
                        //webcam.configure( 'camera' );
                        $(document).ready(function() {
                             $("#hidecam").click(function () {
                                  $("#mycam").css("visibility", "hidden");
                             });

                             $("#showcam").click(function () {
                                  $("#mycam").css("visibility", "visible");
                               });
                       });
                        
                    </script>

                    <!-- Next, write the movie to the page at 320x240 -->
                    <script language="JavaScript">
                        document.write( webcam.get_html(400, 300) );
                    </script>
</span>
                    <!-- Some buttons for controlling things -->
                    <br/><form>
                        <input type=button value="Configuration..." onClick="webcam.configure()">
                        &nbsp;&nbsp;
                        <input type=button value="Photo ( Manuelle)" onClick="take_snapshot();">
                        <input type=button id="hidecam" value="Cache">
                        <input type=button id="showcam" value="Voir"> 
                    </form>

                    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js" type="text/javascript"></script>
                    <script src="js/jquery/urlEncode.js" type="text/javascript"></script>

                    <!-- Code to handle the server response (see test.php) -->
                    <script language="JavaScript">
                        webcam.set_hook( 'onComplete', 'my_completion_handler' );
		
                        setInterval(function take_snapshot() {
                            // take snapshot and upload to server
                            document.getElementById('upload_results').innerHTML = '<h5>iiiiiiii...</h5>';
                            webcam.snap();
                        },20000);
		   
                        function take_snapshot() {
                            // take snapshot and upload to server
                            document.getElementById('upload_results').innerHTML = '<h1>iiiiiiiii...</h1>';
                            webcam.snap();
                        }
                        
                        
                        

                        function my_completion_handler(msg) {
                        
                            var baseurl="http://www.google.com/searchbyimage?sbisrc=cr_1_0_0&image_url=";
                    
                            // extract URL out of PHP output
                            if (msg.match(/(http\:\/\/\S+)/)) {
                                var image_url = RegExp.$1;
                                // show JPEG image in page
                                document.getElementById('upload_results').innerHTML = 
                                    '<h1>OK...</h1>' + 
                                    '<h5> ' + image_url + '</h5>' + 
                                    '<img src="' + image_url + '">';
				
                                //window.open (baseurl+$.URLEncode(image_url), "mywindow");
                                //$('iframe').attr('src', baseurl+$.URLEncode(image_url));
                                  
                                function sendValue(str){
                                    $.post("mytest.php",{ sendValue: str,webcamimage: image_url },
                                    function(data){
//alert(data.returnValue);
                                        //$('iframe').attr('src',data.returnValue);
PopupCenter('', 'Google Image',data.returnValue);
                                        //window.open (data.returnValue, "mywindow");
                                    }, "json");
            
                                }
                                sendValue(baseurl+$.URLEncode(image_url));  
 
                                // reset camera for another shot
                                webcam.reset();
                                
                               
                            }
                            else alert("PHP Error: " + msg);
                        }
                    </script>

                </td><td width=50>&nbsp;</td><td valign=top>
                    <div id="upload_results" style="background-color:#000;"></div>
                </td></tr></table>
        <!--img id="img1" src=""></img-->
<script LANGUAGE="JavaScript">
function PopupCenter(pageURL, title,dest) {
$('table').css('visibility','hidden');
self.parent.tb_remove();
tb_show(" ",dest,null);

/*
w=screen.width-2;
h=screen.height-2;
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
//alert(src);
//alert(dest);
targetWin.document.write("<TITLE></TITLE>");
targetWin.document.write("<BODY BGCOLOR=black>")
//targetWin.document.write("<img height=400 width=300 src='"+src+"'/>")
targetWin.document.write("<img style='margin-left: 250px;margin-top: 200px;' height=300 width=800 src='"+dest+"'/>")
targetWin.document.write("</BODY>")
targetWin.document.write("</HTML>")
targetWin.document.close();*/
} 
</script><a href="javascript:void(0);" onclick="PopupCenter('', 'Version 3.1.2','');">Ouvrir</a><br>

<div class="searchresult">
    <!--iframe WIDTH=320 HEIGHT=240/-->
  </div>
        <div id="result">
        </div>
    </body>
</html>
